home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QRZ! Ham Radio 1
/
QRZ Ham Radio Callsign Database - December 1993.iso
/
unix
/
call.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-11-02
|
2KB
|
140 lines
#include "cb.h"
/*
** call
**
** A UNIX command line program to search the callsign database
**
** Copyright (c) 1993 by Fred Lloyd, AA7BQ
*/
char *s;
int stop_this = 0;
main(argc,argv)
int argc;
char *argv[];
{
char call[8];
char *line;
char *p;
int alph;
int pagit;
int found;
int i;
int len;
long idsize;
char buf[512];
FILE *fp;
if (argc < 2)
{
printf("usage: %s <callsign>\n",argv[0]);
printf(" or: %s -a -n <lookup name>\n",argv[0]);
exit(1);
}
i = 1;
alph = 0;
pagit = 1;
argv++;
while ((i<argc) && argv[0][0] == '-')
{
switch(toupper(argv[0][1]))
{
case 'A': /* make alpha search */
alph = 1;
argv++;
break;
case 'N': /* don't pause flag */
pagit = 0;
argv++;
break;
default:
argv++;
break;
}
i++;
}
if ((fp=fopen("102293.cbk","r")) == NULL)
{
printf("Error opening callbook.db\n");
exit(1);
}
if (alph)
{
alphacall(fp,argc,argv,pagit);
exit(0);
}
printf("\n");
i = 0;
while (*argv)
{
strncpy(call,*argv++,7);
call[7] = '\0';
found = clook(fp,call,buf);
if (found && (strlen(buf) < 20))
{
p = strchr(buf,',');
if (p)
p++;
strcpy(call,p);
found = clook(fp,call,buf);
}
if (found)
{
pcall(buf,printf);
i++;
if (pagit && (i%5 == 0))
n_any_key(0,printf);
}
else
printf("\n%s not found in callbook database.\n",call);
}
exit(0);
}
alphacall(fp,argc,argv,pagit)
FILE *fp;
int argc;
char *argv[];
int pagit;
{
char buf[1024];
char *p;
int found;
char sav[1024];
memset(buf,0,sizeof(buf));
memset(sav,0,sizeof(sav));
while(*argv)
{
strcat(buf,*argv++);
strcat(buf," ");
}
strcpy(sav,buf);
if (p = strrchr(buf,' '))
*p = '\0';
printf("\n");
if ((found = namefind(fp,buf,pagit,printf)) == 0)
printf("\n%s not found in callbook database.\n",buf);
else if (found > 0)
printf("%d record(s) matched pattern '%s'\n",found,sav);
else
printf("Output interrupted after %d record(s) shown\n",
abs(found));
return;
}